Implement, fixes bug #405868. Based on patch from metz81@web.de.
authorRichard Hult <richard@imendio.com>
Tue, 31 Jul 2007 19:25:28 +0000 (19:25 +0000)
committerRichard Hult <rhult@src.gnome.org>
Tue, 31 Jul 2007 19:25:28 +0000 (19:25 +0000)
2007-07-31  Richard Hult  <richard@imendio.com>

* gdk/quartz/gdkwindow-quartz.c: (gdk_window_get_geometry):
Implement, fixes bug #405868. Based on patch from metz81@web.de.

svn path=/trunk/; revision=18560

ChangeLog
gdk/quartz/gdkwindow-quartz.c

index e2767282131e42f428e75b6bc378547bf4a307e7..0412b662bf37f84440985c7c020ecf03785248a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-31  Richard Hult  <richard@imendio.com>
+
+       * gdk/quartz/gdkwindow-quartz.c: (gdk_window_get_geometry):
+       Implement, fixes bug #405868. Based on patch from metz81@web.de.
+
 2007-07-31  Xan Lopez  <xan@gnome.org>
 
        * gtk/gtkentry.c (gtk_entry_completion_key_press): reset the
index d4fc015675e2b34442d9c9b96c2b75b2c688a1a2..63f0197d2bfe4c89b77ee6f3bbcd5ebd9d433daf 100644 (file)
@@ -1310,9 +1310,78 @@ gdk_window_get_geometry (GdkWindow *window,
                         gint      *height,
                         gint      *depth)
 {
-  g_return_if_fail (GDK_IS_WINDOW (window));
+  GdkWindowImplQuartz *impl;
+  NSRect ns_rect;
 
-  /* FIXME: Implement */
+  g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
+
+  if (!window)
+    window = _gdk_root;
+  
+  if (GDK_WINDOW_DESTROYED (window))
+    return;
+
+  impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl);
+  if (window == _gdk_root)
+    {
+      if (x) 
+        *x = 0;
+      if (y) 
+        *y = 0;
+
+      if (width) 
+        *width = impl->width;
+      if (height)
+        *height = impl->height;
+    }
+  else if (WINDOW_IS_TOPLEVEL (window))
+    {
+      ns_rect = [impl->toplevel contentRectForFrameRect:[impl->toplevel frame]];
+
+      /* This doesn't work exactly as in X. There doesn't seem to be a
+       * way to get the coords relative to the parent window (usually
+       * the window frame), but that seems useless except for
+       * borderless windows where it's relative to the root window. So
+       * we return (0, 0) (should be something like (0, 22)) for
+       * windows with borders and the root relative coordinates
+       * otherwise.
+       */
+      if ([impl->toplevel styleMask] == NSBorderlessWindowMask)
+        {
+          if (x)
+            *x = ns_rect.origin.x;
+          if (y)
+            *y = _gdk_quartz_window_get_inverted_screen_y (ns_rect.origin.y + ns_rect.size.height);
+        }
+      else 
+        {
+          if (x)
+            *x = 0;
+          if (y)
+            *y = 0;
+        }
+
+      if (width)
+        *width = ns_rect.size.width;
+      if (height)
+        *height = ns_rect.size.height;
+    }
+  else
+    {
+      ns_rect = [impl->view frame];
+      
+      if (x)
+        *x = ns_rect.origin.x;
+      if (y)
+        *y = ns_rect.origin.y;
+      if (width)
+        *width  = ns_rect.size.width;
+      if (height)
+        *height = ns_rect.size.height;
+    }
+    
+  if (depth)
+      *depth = gdk_drawable_get_depth (window);
 }
 
 gboolean